package com.dragon.modules.yuegou.enums;

import javax.annotation.Nullable;
import java.util.Map;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 悦商圈APP安卓版菜单
 * 
 * @author liuwu
 *
 */
public enum AppAndroidMenu implements IMenu {

	/**
	 * 根节点
	 */
	ROOT(200, "悦商圈APP安卓版", "root", 0),
	// 一级
	/**
	 * 首页动态菜单
	 */
	MAIN(202, "首页动态菜单", "main", 200),
	/**
	 * 个人中心动态菜单
	 */
	USER(203, "个人中心动态菜单", "user", 200),
	/**
	 * 营销菜单
	 */
	MARKETING(204, "营销菜单", "marketing", 200),
	// 二级
	// 首页动态菜单
	/** 优质好货 */
	MAIN_GOODS(210, "优质好货", "mainGoods", 202),
	/** 积分商城 */
	MAIN_SCORE_SHOP(211, "积分商城", "mainScoreShop", 202),
	/** 扫码支付 */
	MAIN_SCAN(212, "扫码支付", "mainScan", 202),
	/** 积分兑换 */
	MAIN_SCORE(213, "积分兑换", "mainScore", 202),
	/** 超值悦卡 */
	MAIN_HAPPY_CARD(214, "超值悦卡", "mainHappyCard", 202),
	/** 品牌悦店 */
	MAIN_SHOP(215, "品牌悦店", "mainShop", 202),
	/** 优惠停车 */
	MAIN_STOP_CAR(216, "优惠停车", "mainStopCar", 202),
	/** 精选套餐 */
	MAIN_SET_GOODS(217, "精选套餐", "mainSetGoods", 202),
	/** 商城服务 */
	MAIN_SERVICE(218, "商场服务", "mainService", 202),
	// 个人中心动态菜单
	/** 我的钱包 */
	USER_WALLET(220, "我的钱包", "userWallet", 203),
	/** 我的订单 */
	USER_ORDER(221, "我的订单", "userOrder", 203),
	/** 我的停车 */
	USER_PARK(222, "我的停车", "userPark", 203),
	/** 交易记录 */
	USER_TRAD_RECORD(223, "交易记录", "userTradRecord", 203),
	/** 我的助力 */
	USER_HELP(224, "我的助力", "userHelp", 203),
	/** 消息 */
	USER_MSG(225, "消息", "userMsg", 203),
	/** 打卡 */
	USER_SIGN(226, "打卡", "userSign", 203),
	/** 修改资料 */
	USER_MODIFY(227, "修改资料", "userModify", 203),
	/** 粉丝关注 */
	USER_FANSCARE(228, "粉丝关注", "userFansCare", 203),
	/** 隐私设置 */
	USER_SETTING(229, "隐私设置", "userSetting", 203),
	/** 收藏 */
	USER_FAVORITE(230, "收藏", "userFavorite", 203),
	/** 安全中心 */
	USER_SAFE_CENTER(231, "安全中心", "userSafeCenter", 203),
	/** 退出登录 */
	USER_LOGOUT(232, "退出登录", "userLogout", 203),
	/** 我的拼团 */
	USER_GROUPN(233, "我的拼团 ", "userGroupn", 203),
	/** 我的购物车 */
	USER_SHOP_CAR(234, "购物车", "userShopCar", 203),
    /** 会员福利 */
    USER_WALFARE(235, "会员福利", "userWelfare", 203),
    /** 红包卡券 */
    USER_CARD_VOUCHER(236, "红包卡券", "userCardVoucher", 203),

    // 营销菜单
	/** 秒杀 */
	ACTIVITY_SECONDS_KILL(240, "秒杀", "activitySecondsKill", 204),
	/** 助力 */
	ACTIVITY_HELP(241, "助力", "activityHelp", 204),
	/** 限时抢购 */
	ACTIVITY_TIME_LIMIT(242, "限时抢购", "activityTimeLimit", 204),
	/** 拼团 */
	ACTIVITY_FIGHT_GROUP(243, "拼团", "activityFightGroup", 204),
	/** 收货地址 */
	SHIPPING(245, "收货地址", "shipping", 203),
	/** 积分签到 */
	MAIN_SIGN(244, "积分签到", "mainSign", 202),
	/** 圈子 */
	CIRCLE(246, "圈子", "circle", 202),
	/**意见反馈*/
	OPINION(247, "意见反馈", "opinion", 203);
	/**
	 * 菜单ID
	 */
	private int id;

	/**
	 * 菜单别名（中文名，展示给用户看的名称）
	 */
	private String alias;

	/**
	 * 菜单路径（菜单标识，并不对应接口路径）
	 */
	private String path;

	/**
	 * 父菜单ID，0表示没有父菜单
	 */
	private int parentId;

	private AppAndroidMenu(int id, String alias, String path, int parentId) {
		this.id = id;
		this.alias = alias;
		this.path = path;
		this.parentId = parentId;
	}

	@Override
	public int getId() {
		return id;
	}

	@Override
	public String getAlias() {
		return alias;
	}

	@Override
	public String getPath() {
		return path;
	}

	@Override
	public int getParentId() {
		return parentId;
	}

	/**
	 * 根据路径获取菜单
	 * 
	 * @param path 菜单路径（标识）
	 * @return 菜单
	 */
	@Nullable
	public static AppAndroidMenu from(String path) {
		if (path == null) {
			return null;
		}
		return PATH_MAP.get(path);
	}

	/**
	 * Path Map for Menu
	 */
	private static final Map<String, AppAndroidMenu> PATH_MAP = Stream.of(AppAndroidMenu.values())
			.collect(Collectors.toMap(AppAndroidMenu::getPath, UnaryOperator.identity()));

}
